{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dfb59168",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Prime numbers less than or equal to 20: [2, 3, 5, 7, 11, 13, 17, 19]\n"
     ]
    }
   ],
   "source": [
    "# Sieve of Eratosthenes\n",
    "def sieve_of_eratosthenes(n):\n",
    "    primes = [True] * (n + 1)\n",
    "    primes[0] = primes[1] = False\n",
    "    for i in range(2, int(n**0.5) + 1):\n",
    "        if primes[i]:\n",
    "            for j in range(i * i, n + 1, i):\n",
    "                primes[j] = False\n",
    "    return [x for x in range(n + 1) if primes[x]]\n",
    "\n",
    "# Example: Finding all primes less than or equal to 20\n",
    "limit = 20\n",
    "prime_numbers = sieve_of_eratosthenes(limit)\n",
    "print(f'Prime numbers less than or equal to {limit}: {prime_numbers}')\n",
    "# Prime numbers less than or equal to 20: [2, 3, 5, 7, 11, 13, 17, 19]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "354cef17",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
